#pragma once

#include "..\\headers.default.h"
#include "..\\headers.cv.h"
#include "..\\headers.ipfe.h"

using namespace loirey;

class CImageWindowContext
{
public:
	class CSlidingConfig
	{
	public:
		double BaseW, BaseH;
		double ScaleFactor;
		double xStride, yStride;
	};
public:
	class CSlidingWindowList
	{
	public:
		int Size;
		CSimpleTypeArray<CImagePyramidPosition> ippList;

	public:
		CSlidingWindowList();
		void Clear();
		void PushBack(const CImagePyramidPosition& ipp);
		void BuildWindowList(double W, double H, const CSlidingConfig& SlidingConfig, bool fClearFirst);
		void GenerateRandomWindow(CImagePyramidPosition& dst_ipp);
	};

public:
	template<typename T>
	static void ComputeImagePyramidPosition(
		CImagePyramidPosition& DstImagePyramidPosition,
		const CRectBox<T>& SrcOriginalRectBox,
		double BaseW, double BaseH
		)
	{
		DstImagePyramidPosition.InitNew(
			SrcOriginalRectBox.x+SrcOriginalRectBox.w/2.0, SrcOriginalRectBox.y+SrcOriginalRectBox.h/2.0,
			BaseW/SrcOriginalRectBox.w, BaseH/SrcOriginalRectBox.h
			);
	}
	template<typename T>
	static void ComputeRectBox(
		CRectBox<T>& DstOriginalRectBox,
		const CImagePyramidPosition& SrcImagePyramidPosition,
		double BaseW, double BaseH
		)
	{
		DstOriginalRectBox.w = CMyMath::TranslateNumber_Round(BaseW / SrcImagePyramidPosition.xScale, (T)0);
		DstOriginalRectBox.h = CMyMath::TranslateNumber_Round(BaseH / SrcImagePyramidPosition.yScale, (T)0);
		DstOriginalRectBox.x = (T)(SrcImagePyramidPosition.xOld - DstOriginalRectBox.w / 2.0 + EPS);
		DstOriginalRectBox.y = (T)(SrcImagePyramidPosition.yOld - DstOriginalRectBox.h / 2.0 + EPS);
	}
};

